package com.wymobilearchitecture.demo.kt;

public class A05_generic {
    //Lev 1
    static class Food{}

    //Lev 2
    static class Fruit extends Food{}
    static class Meat extends Food{}

    //Lev 3
    static class Apple extends Fruit {}
    static class Banana extends Fruit{}
    static class Pork extends Meat{}
    static class Beef extends Meat{}

    //Lev 4
    class ReadApple extends Apple{}
    class GreenApple extends Apple{}

    //盘子类
    public static class Plate<T>{

        private T item;
        public Plate(T item){
            this.item = item;
        }
        public void setItem(T item) {
            this.item = item;
        }
        public T getItem() {
            return item;
        }
    }
    public static void main(String[] args) {
//        Plate<Fruit> plate = new Plate<Apple>(new Apple());
        //上界通配符- 以 Fruit 为最高边界
        Plate<? extends Fruit> plate1 = new Plate<Apple>(new Apple());
        //下界通配符- 以 Fruit 为最底边界
        Plate<? super Fruit> plate2 = new Plate<>(new Food());
    }
}


